package com.example.yuejian.yuejian.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.example.yuejian.yuejian.R;

public class MySettingActivity extends AppCompatActivity {

    private  ImageView btn_back;
    private RelativeLayout rl_uerinfo;
    private RelativeLayout rl_clear;
    private RelativeLayout rl_help;
    private RelativeLayout rl_logout;
    private RelativeLayout rl_edit_password;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_setting);
        back();
        initViews();
        initEvents();
    }
    private void initViews()
    {
        rl_uerinfo=(RelativeLayout)findViewById(R.id.my_setting_userinfo);
        rl_clear=(RelativeLayout)findViewById(R.id.my_setting_clear_cache);
        rl_help=(RelativeLayout)findViewById(R.id.my_setting_help);
        rl_logout=(RelativeLayout)findViewById(R.id.my_setting_logout);
        rl_edit_password=(RelativeLayout)findViewById(R.id.my_setting_edit_password);
    }
    private  void initEvents()
    {
        rl_uerinfo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(MySettingActivity.this,UserInfoActivity.class);
                startActivity(intent);
            }
        });
        rl_clear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });
        rl_help.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });
        rl_edit_password.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(MySettingActivity.this,EditPasswordActivity.class);
                startActivity(intent);
            }
        });
        rl_logout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getApplication(),"注销成功",Toast.LENGTH_LONG).show();
                SharedPreferences sharedPreferences=getSharedPreferences("UserInfo", MODE_PRIVATE);
                SharedPreferences.Editor editor=sharedPreferences.edit();//获取编辑器
                //int uid=Integer.parseInt(userid);
                String uid="";
                editor.putString("user_id", uid);

                   /* sharedPreferences = getSharedPreferences("UserCheck", MODE_PRIVATE);
                    editor = sharedPreferences.edit();*/
                    /* boolean is=false;
                    editor.putBoolean("check",is);*/
                editor.commit();
                Intent intent=new Intent();
                intent.setClass(MySettingActivity.this,LoginActivity.class);
                startActivity(intent);
            }
        });
    }
    private void back()
    {
        btn_back=(ImageView)findViewById(R.id.imgBtn_mysetting_back);
        btn_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }
}
